package net.neptech.listeners;

import net.neptech.model.message.Message;
import net.neptech.utils.SmsSSample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.jms.AcknowledgeMode;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Service;

@Service
public class CallSlotListeners {

    @Autowired
    private SmsSSample smsSSample;

    @KafkaListener(topics = "message_topics",groupId = "message_send")
    public void listen(@Payload  Message message, Acknowledgment ack) {
        // 处理接收到的消息
        String s = smsSSample.sendSms(message.getPhone(), message.getContent());
        System.out.println(s);
        ack.acknowledge();
        System.out.println("Received message: " + message);
    }
}
